package com.infore.airsupervise.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * 吐司工具类
 *
 * @author: dingxinlin
 */
public class ToastUtil {

    private static Toast toast;

    /**
     * 关闭Toast
     */
    private static void cancelToast() {
        if (toast != null) {
            toast.cancel();
            toast = null;
        }
    }

    /**
     * 短时间Toast
     */
    public static void showShort(Context ctx, String text) {
        cancelToast();
        toast = Toast.makeText(ctx, text, Toast.LENGTH_SHORT);
        toast.show();
    }

    /**
     * 长时间Toast
     */
    public static void showLong(Context ctx, String text) {
        cancelToast();
        Toast.makeText(ctx, text, Toast.LENGTH_LONG).show();
    }

    public static void showLoadEnd(Context ctx) {
        showShort(ctx, "加载完了");
    }

}
